Skip to content

🌐 [translation-sync] [need_for_speed.md] Update np.random → Generator API#119

Merged
mmcky merged 2 commits into
mainfrom
translation-sync-2026-05-05T13-05-00-pr-545
May 14, 2026
Merged

🌐 [translation-sync] [need_for_speed.md] Update np.random → Generator API#119
mmcky merged 2 commits into
mainfrom
translation-sync-2026-05-05T13-05-00-pr-545

Conversation

@mmcky

@mmcky mmcky commented May 5, 2026

Copy link
Copy Markdown
Contributor

Automated Translation Sync

This PR contains automated translations from QuantEcon/lecture-python-programming.

Source PR

#545 - [need_for_speed.md] Update np.random → Generator API

Files Updated

  • ✏️ lectures/need_for_speed.md
  • ✏️ .translate/state/need_for_speed.md.yml

Details

  • Source Language: en
  • Target Language: fa
  • Model: claude-sonnet-4-6

This PR was created automatically by the translation action.

@mmcky
mmcky requested review from Copilot May 5, 2026 13:05
@mmcky mmcky added action-translation PRs created by QuantEcon/action-translation automated Automated sync PR opened by action-translation labels May 5, 2026
@netlify

netlify Bot commented May 5, 2026

Copy link
Copy Markdown

Deploy Preview for majestic-griffin-10b166 ready!

Name Link
🔨 Latest commit 4d7f1b2
🔍 Latest deploy log https://app.netlify.com/projects/majestic-griffin-10b166/deploys/69f9eb0298a6c800085fa98d
😎 Deploy Preview https://deploy-preview-119--majestic-griffin-10b166.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown

✅ Translation Quality Review

Verdict: PASS | Model: claude-sonnet-4-6 | Date: 2026-05-05


📝 Translation Quality

Criterion Score
Accuracy 8/10
Fluency 8/10
Terminology 9/10
Formatting 9/10
Overall 8.4/10

Summary: The translation of the 'Vectorization vs pure Python loops' section is generally accurate and well-formatted. Terminology follows the reference glossary correctly. Minor fluency issues exist around the phrasing of 'non-vectorized code' and the step description 'draw n uniforms', which could be expressed more naturally in Persian. The inline English code comment is left untranslated, which may be intentional but is worth flagging for consistency. Technical terminology is consistently and correctly applied throughout the changed section, matching the reference glossary (e.g., 'برداری‌سازی' for Vectorization, 'حلقه' for loop). The MyST/Markdown formatting, including code cells, directives, and list structures, is fully preserved in the changed section. The overall structure and meaning of the 'Vectorization vs pure Python loops' section is accurately conveyed, including the three-step breakdown of the vectorized operation.

Suggestions:

  • Section 'برداری‌سازی در مقابل حلقه‌های پایتون خالص', code comment: 'y = 0 # Will accumulate and store sum' — The inline code comment is left in English. Consider translating to '# مقدار جمع را ذخیره و انباشت می‌کند' for consistency with a Persian-language document.
  • Section 'برداری‌سازی در مقابل حلقه‌های پایتون خالص', step list: '1. n uniform را بکشید' — The phrase 'بکشید' (draw/pull) is an unusual rendering of 'draw n uniforms'. A clearer phrasing would be '1. n عدد تصادفی یکنواخت تولید کنید' to match the technical meaning.
  • Section 'برداری‌سازی در مقابل حلقه‌های پایتون خالص': 'در اینجا مقداری کد غیر برداری شده وجود دارد که از یک حلقه بومی پایتون برای تولید، مجذور کردن و سپس جمع کردن تعداد زیادی متغیر تصادفی استفاده می‌کند' — 'کد غیر برداری شده' is slightly awkward; 'کد بدون برداری‌سازی' or 'کد غیربرداری‌سازی‌شده' would be more natural.
  • Section 'برداری‌سازی در مقابل حلقه‌های پایتون خالص': 'کد برداری شده زیر از NumPy استفاده می‌کند که به زودی آن را به تفصیل بررسی خواهیم کرد، تا همان کار را انجام دهد.' — This sentence is awkward due to the embedded relative clause. Suggested: 'کد برداری‌سازی‌شده زیر از NumPy—که به زودی آن را به تفصیل بررسی خواهیم کرد—برای انجام همان کار استفاده می‌کند.'

🔍 Diff Quality

Check Status
Scope Correct
Position Correct
Structure Preserved
Heading-map Correct
Overall 10/10

Summary: The translation correctly mirrors the source change, replacing the old vectorized code block with the new RNG-based implementation in the same position, with no structural or metadata issues.


This review was generated automatically by action-translation review mode.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Syncs the Persian translation of need_for_speed.md with upstream changes that migrate an example from the legacy np.random API to the newer numpy.random.Generator API, keeping the translated lecture aligned with the source repository.

Changes:

  • Updated the NumPy vectorization example to create a rng = np.random.default_rng() and use rng.uniform(...) instead of np.random.uniform(...).
  • Updated translation sync state metadata (source-sha, synced-at) for need_for_speed.md.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
lectures/need_for_speed.md Updates the random sampling example to use NumPy’s Generator API (default_rng + rng.uniform).
.translate/state/need_for_speed.md.yml Updates translation sync tracking metadata to reflect the new upstream source revision and sync date.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown

@github-actions
github-actions Bot temporarily deployed to pull request May 5, 2026 13:10 Inactive
@mmcky
mmcky merged commit c2ce8ef into main May 14, 2026
13 checks passed
@mmcky
mmcky deleted the translation-sync-2026-05-05T13-05-00-pr-545 branch May 14, 2026 10:12
mmcky added a commit that referenced this pull request Jul 21, 2026
…le -W (#137)

* Migrate translation workflows to @v0, adopt the review template, enable -W

Moves review and rebase off the exact `@v0.16.1` pin onto the floating
`@v0` tag, per the pin policy settled in
QuantEcon/project-translation#9, and aligns the review workflow with the
upstream template in action-translation
docs/user/tutorials/connect-existing.md.

Two substantive changes beyond the pin:

**Concurrency moves from workflow level to job level**, and
`cancel-in-progress` from false to true. The previous comment argued
that job-level `true` was unsafe because an 'automated' label event
would cancel the in-flight review for 'action-translation' and then
skip its own job via the filter, leaving no review at all. That was
reasoned from the GitHub docs and never tested, and production
disproved it: across roughly 15 live opportunities on
lecture-intro.zh-cn the group was entered only after the `if` passed,
the 'automated' event skipped without cancelling, and a review was
posted every time. The stale rationale is replaced rather than left in
place.

**A `permissions` block is added** — v0.17.0's review dedupe deletes
superseded comments, which requires `pull-requests: write`.

The pin was two releases behind, which matters here: v0.18.0 carries
the fix for a review-mode defect where a model response missing a
criterion score became NaN and rendered as an automatic FAIL on
otherwise clean PRs. See QuantEcon/action-translation#102.

Separately, `ci.yml` gains `-W` on the notebook build. This repo's
publish.yml already builds strict, so the PR gate was weaker than the
publish gate — a corrupted sync could merge green and then break the
published site. Coverage is 26 of 26 lectures with a `_toc.yml`
identical to source, so there are no untranslated-lecture references
for the flag to trip on. The strict build is the last line of defence
against the silent-corruption class in
QuantEcon/action-translation#118 and #119, both of which surfaced only
because a downstream repo built with -n -W.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* Rebase: also match resync/* branches (action-translation v0.18.1)

The rebase workflow only fired for `translation-sync-*` branches, which
the Action's sync mode creates. The CLI's `translate forward --github`
creates `resync/{stem}` branches, so merging one resync PR never
rebased its siblings — during a drift-recovery wave that leaves a stack
of open PRs whose bases go stale with every merge.

Fixed engine-side in action-translation v0.18.1, but the action-side
half is not sufficient on its own: this `if` gates whether the job runs
at all, and it runs before the action does. Both layers must list both
prefixes or the result is a job that never starts.

Brings this file in step with the upstream template as of that release.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action-translation PRs created by QuantEcon/action-translation automated Automated sync PR opened by action-translation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants